package com.ruoyi.system.controller.web;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.csp.sentinel.util.AssertUtil;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.utils.CommonStreamUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.common.core.web.page.WebTableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.domain.BaseContest;
import com.ruoyi.system.domain.BaseContestBindingGroup;
import com.ruoyi.system.domain.dto.Web.ContestBindingDto;
import com.ruoyi.system.service.IBaseContestService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * web联赛Controller
 */
@ApiOperation("联赛")
@RestController
@RequestMapping("/web/contestBinding")
public class BaseWebContestBindingController extends BaseController
{
    @Autowired
    private IBaseContestService baseContestService;

    @Autowired
    TokenService tokenService;


    /**
     * 查询联赛分组列表
     */
    @PostMapping("/getContestBindingGroupList")
    public WebTableDataInfo getContestBindingGroupList(@RequestBody PageDomain pageDomain){
        PageHelper.startPage(pageDomain.getPageNum(), pageDomain.getPageSize());
        return getWebDataTable(baseContestService.getContestBindingGroupList());
    }

    /**
     * 删除分组
     */
    @PostMapping("/deleteContestBindingGroup")
    public AjaxResult deleteContestBindingGroup(@RequestBody BaseContestBindingGroup baseContestBindingGroup){
        AssertUtil.notNull(baseContestBindingGroup.getId(), "绑定组不存在");
        return toAjax(baseContestService.deleteContestBindingGroup(baseContestBindingGroup.getId()));
    }

    /**
     * 新增分组
     */
    @PostMapping("/addContestBindingGroup")
    public AjaxResult addContestBindingGroup(@RequestBody BaseContestBindingGroup baseContestBindingGroup){
        return toAjax(baseContestService.addContestBindingGroup(baseContestBindingGroup));
    }

    /**
     * 查询分组内 联赛列表
     */
    @PostMapping("/getContestBindingList")
    public AjaxResult getContestBindingList(@RequestBody BaseContestBindingGroup contestBindingGroup){
        return success(baseContestService.getContestBindingList(contestBindingGroup));
    }


    /**
     * 联赛绑定 新
     */
    @PostMapping("/contestBindingNew")
    public AjaxResult contestBindingNew(@RequestBody ContestBindingDto ContestBindingDto) {
        return toAjax(baseContestService.contestBindingNew(ContestBindingDto));
    }
}
